import Vue from 'vue'
import Vuex from 'vuex'

import { getSource } from '@/views/map/config/vecLayer'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    draw: false,
    userinfo: {},
    noAction: true
  },
  getters: {
  },
  mutations: {
    updateDraw(state, val) {
      this.state.draw = val;
    },
    updateUserinfo(state, val) {
      state.userinfo = val
      state.noAction = val.account === 'admin' ? false : true
    }
  },
  actions: {
    async refreshWFS(state, wfsData) {
      wfsData.layer.getSource().clear()
      let source = await getSource(wfsData.type)
      wfsData.layer.setSource(source)
    }
  },
  modules: {
  }
})
